package cn.exrick.xboot.modules.content.entity;

import cn.exrick.xboot.base.XbootBaseEntity;
import cn.exrick.xboot.common.constant.CommonConstant;
import cn.exrick.xboot.common.utils.SnowFlakeUtil;
import cn.exrick.xboot.modules.base.entity.Permission;
import cn.exrick.xboot.mybaitsPlus.BaseEntity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * @author Exrick
 */
@Data
@Entity
@Table(name = "hont_user")
@TableName("hont_user")
@ApiModel(value = "前台用户")
public class HontUser extends BaseEntity {
    private static final long serialVersionUID = 1L;
    @Id
    @TableId
    @ApiModelProperty(value = "唯一标识")
    private String id = String.valueOf(SnowFlakeUtil.getFlowIdInstance().nextId());


    @ApiModelProperty(value = "用户名")
    @Column(name = "user_name",unique = true, nullable = false)
    private String userName;

    @ApiModelProperty(value = "密码")
    private String passWord;

    @ApiModelProperty(value = "昵称")
    @Column(name = "nick_name")
    private String nickName;

    @ApiModelProperty(value = "手机")
    @Column(name = "mobile")
    private String mobile;

    @ApiModelProperty(value = "邮件")
    private String email;

    @ApiModelProperty(value = "省市县地址")
    private String address;

    @ApiModelProperty(value = "街道地址")
    private String street;

    @ApiModelProperty(value = "性别")
    private String sex;

    @ApiModelProperty(value = "openid")
    private String openId;

    @ApiModelProperty(value = "密码强度")
    @Column(length = 2)
    private String passStrength;

    @ApiModelProperty(value = "用户头像")
    //@Column(length = 1000)
    private String avatar = CommonConstant.USER_DEFAULT_AVATAR;

    @ApiModelProperty(value = "用户类型 0普通用户 1管理员 ")
    private Integer type = CommonConstant.USER_TYPE_NORMAL;

    @ApiModelProperty(value = "前台用户使用  用户等级 1 一级用户 2 二级用户 ")
    private Integer userLevel;

    @ApiModelProperty(value = "状态 默认0正常 -1拉黑")
    private Integer status = CommonConstant.USER_STATUS_NORMAL;

    @ApiModelProperty(value = "描述/详情/备注")
    private String description;

    @ApiModelProperty(value = "所属部门id")
    private String departmentId;

    @ApiModelProperty(value = "所属部门id")
    private String departmentCopyId;

    @ApiModelProperty(value = "岗位id")
    private String postId;

    @ApiModelProperty(value = "认证状态 0.未认证1.已认证")
    private Integer approve;

    @ApiModelProperty(value = "是否是后台管理员 0.不是，1是")
    private Integer isBackstage;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "最近登录时间")
    private Date updateLastTime;

    @Transient
    @TableField(exist=false)
    @ApiModelProperty(value = "所属部门名称")
    private String departmentTitle;

    @Transient
    @TableField(exist=false)
    @ApiModelProperty(value = "用户拥有角色")
    private List<String> departmentIds;

    @Transient
    @TableField(exist=false)
    @ApiModelProperty(value = "所属班名称")
    private String departmentCopyTitle;

    @Transient
    @TableField(exist=false)
    @ApiModelProperty(value = "所属岗位名称")
    private List<String> postTile;

    @Transient
    @TableField(exist=false)
    @ApiModelProperty(value = "岗位id")
    private List<String> postIds;

    @Transient
    @TableField(exist=false)
    @ApiModelProperty(value = "用户拥有角色")
    private List<HontRole> roles;
    @Transient
    @TableField(exist=false)
    @ApiModelProperty(value = "角色id")
    private String roleId;
    @Transient
    @TableField(exist=false)
    @ApiModelProperty(value = "角色id")
    private Integer roleLevel;

    @Transient
    @TableField(exist=false)
    @ApiModelProperty(value = "用户拥有的权限")
    private List<HontPermission> permissions;

}